/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.DesignPatterns.structural.Composite;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Nashief
 */
public class Composite implements Component {
 
    List<Component> c=new ArrayList<Component>();  
    
    @Override
    public void sayHello() {
    
        for(Component component: c){
        component.sayHello();
        }
        
    }

    @Override
    public void sayGoodBye() {
        for(Component component: c){
        component.sayGoodBye();
        }
    }
    public void add(Component component){
    c.add(component);
    }
    public void remove(Component component){
    c.remove(component);
    }
    
    public List<Component> getComponents(){
    return c;
    }
    public Component getComponent(int index){
    return c.get(index);
    } 
    
}
